package com.colin.aiyi.dao.ImpxUtils3_de;

import com.colin.aiyi.app.Constant;
import com.colin.aiyi.entity.YiMing;
import com.colin.aiyi.presenter.Interface.Callback;

import org.xutils.http.RequestParams;

/**
 * Created by hl on 2017/6/6.
 */

@Deprecated
public class ImpReferrer extends AbsServicexUtils<YiMing> {

    @Override
    public void onSuccess(String result) {
        super.onSuccess(result);
        YiMing baseResponse=gson.fromJson(result,YiMing.class);
        callback.onSuccess(baseResponse);
    }

    /**********
     * 详情
     * @param callback
     */
    @Override
    public void getTById(Callback<YiMing> callback, String id) {
        super.getTById(callback, id);
        RequestParams params=new RequestParams(Constant.AUDIO_detail);
        params.addBodyParameter("accessToken",id);
        sendToServer(params);
    }

    /********
     * 修改
     * roleId	是	string	角色ID
     content	是	string	内容
     urls	是	string	多个用字符串拼接
     * @param callback
     * @param yiMing
     */
    @Override
    public void updateT(Callback<YiMing> callback, YiMing yiMing) {
        super.updateT(callback, yiMing);
        RequestParams params=new RequestParams(Constant.AUDIO_update);
        params.addBodyParameter("roleId",yiMing.getData().getRoleId()+"");//	是	string	角色ID
        params.addBodyParameter("content",yiMing.getData().getContent());//	是	string	内容
        StringBuffer stringBuffer=new StringBuffer();
        for (YiMing.DataBean.UrlsBean urlsBean : yiMing.getData().getUrls()) {
            stringBuffer.append(urlsBean).append(",");
        }
        stringBuffer.replace(stringBuffer.length()-2,stringBuffer.length()-1,"");
        params.addBodyParameter("urls",stringBuffer.toString());//	是	string	多个用字符串拼接
        sendToServer(params,1);
    }


    @Override
    public void saveT(Callback<YiMing> callback, YiMing yiMing) {
        super.saveT(callback, yiMing);
        RequestParams params=new RequestParams(Constant.AUDIO_save);
        params.addBodyParameter("roleId",yiMing.getData().getRoleId()+"");//	是	string	角色ID
        params.addBodyParameter("content",yiMing.getData().getContent());//	是	string	内容
        StringBuffer stringBuffer=new StringBuffer();
        for (YiMing.DataBean.UrlsBean urlsBean : yiMing.getData().getUrls()) {
            stringBuffer.append(urlsBean).append(",");
        }
        stringBuffer.replace(stringBuffer.length()-2,stringBuffer.length()-1,"");
        params.addBodyParameter("urls",stringBuffer.toString());//	是	string	多个用字符串拼接
        sendToServer(params,1);
    }
}
